package com.weiyi.mashangzhu.Landlord.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.weiyi.mashangzhu.R;
import java.util.List;

/**
 * Created by win7 on 2017/9/25.
 */

public class NextAdapter extends BaseAdapter {
    List<String> list;
    Context context;
    String type;

    public NextAdapter(List<String> list, Context context, String type) {
        this.list = list;
        this.context = context;
        this.type = type;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
               convertView = LayoutInflater.from(context).inflate(R.layout.item_next, null);
            viewHolder.count = (TextView) convertView.findViewById(R.id.tv);
            viewHolder.next= (ImageView) convertView.findViewById(R.id.img);
            viewHolder.finish = (TextView) convertView.findViewById(R.id.finish_tv);
            convertView.setTag(viewHolder);

        }
        viewHolder = (ViewHolder) convertView.getTag();
        viewHolder.count.setText(list.get(position)+"");
        viewHolder.finish.setVisibility(View.VISIBLE);
        if (type.equals("img_no")){
            viewHolder.next.setVisibility(View.GONE);
        }else {
            viewHolder.next.setVisibility(View.VISIBLE);
        }
        return convertView;
    }

    class ViewHolder {
        TextView count,finish;
        ImageView next;
    }
}
